package com.fintech.cloudfunc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.function.context.FunctionEntry;
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Flux;

import java.util.Date;
import java.util.function.Function;

//@FunctionScan
@SpringBootApplication
public class CloudfuncApplication {

    @Bean
    public Function<String, String> hello() {
        return name -> "Hello from cloud to the guest: " + name;
    }

    @Bean
    public Function<String, String> sayhello() {
        return name -> "Hello from cloud to the guest: " + name;
    }

    @Bean
    @FunctionEntry("movieInfo")
    public Function<Flux<String>, Flux<Movie>> getMovieInfo() {
        return flux -> flux.map(value -> new Movie(value, new Date()));
    }

    public static void main(String[] args) {
        SpringApplication.run(CloudfuncApplication.class, args);
    }
}
